<template lang="pug">
  div
    s-table(
      ref="table"
      :column="tableObj.column"
      :filterProps="{items: filterItems}"
      :queryFn="tableObj.getList"
      title="生物特征库"
      )
      .table-operator(slot="table-operator")
        el-button(size="small" type="success" @click="addObj.visible = true") 新增
        el-button(size="small" type="primary" @click="importToggle(1)")  基本信息导入
        el-button(size="small" type="primary" @click="importToggle(2)")  模板批量导入
    modal-form(
      :formItems="addItems"
      :visible.sync="addObj.visible"
      title="人员信息导入"
      :formSubmit="addSubmit"
    )
    import-modal(:type="importObj.type" :visible.sync="importObj.visible" :type="importObj.type")
</template>
<script>
import { STable, ModalForm } from '@/components' 
import { getPersonList } from '@/api/libary'
import ImportModal from './DoctorImportModal'

const column = [
  {
    prop: 'name',
    label: '姓名'
  },
  {
    prop: 'idcard',
    label: '身份证'
  },
  {
    prop: 'sex',
    label: '性别',
    rest: {
      align: 'center'
    }
  },
  {
    prop: 'doctorTypeName',
    label: '身份类别',
    rest: {
      align: 'center'
    }
  },
  {
    prop: 'doctorCode',
    label: '医师/药师编号'
  },
  {
    prop: 'orgName',
    label: '最近打卡机构'
  },
  {
    prop: 'recogTime',
    label: '最近打卡时间',
    rest: {
      align: 'center',
      sortable: true
    }
  },
  {
    prop: 'operator',
    label: '操作',
    width: '260',
    rest: {
      align: 'center'
    }
  }
]

export default {
  name: 'Biology',
  components: {
    STable,
    ImportModal,
    ModalForm
  },
  data () {
    return {
      tableObj: {
        column,
        getList: getPersonList
      },
      addObj: {
        visible: false
      },
      importObj: {
        visible: false,
        type: 1
      }
    }
  },
  computed: {
    addItems () {
      return [
        {
          key: 'name',
          label: '人员名称'
        },
        {
          key: 'idcard',
          label: '身份证号'
        },
        {
          key: 'bioType',
          label: '模板类别',
          type: 'radiobutton',
          options: this.dict.bioType
        },
        {
          key: 'pic',
          label: '上传照片',
          type: 'upload',
          avatarFlag: true
        }
      ]
    },
    filterItems () {
      return [
        {
          key: 'keywords',
          label: '关键信息'
        },
        {
          key: 'bioType',
          label: '生物类型',
          type: 'selectdict',
          dictKey: 'bioType'
        }
      ]
    }
  },
  created () {
    console.log(this.$route)
  },
  methods: {
    importToggle (type) {
      console.log(type)
      this.importObj = {
        type,
        visible: true
      }
    },
    addSubmit (vals) {
      console.log(vals)
    }
  }
}
</script>

